Dear all, I have a Problem in dxl an hope that anyone has a solution for this. What I want to do: I want to create a TextFile with oleMethods and then write text in this Textfile. Creating a TextFile is no Problem... see below. OleAutoObj Scripting = oleCreateAutoObject("Scripting.FileSystemObject"); OleAutoArgs autoArgs = create();
string ScriptingObj = "Scripting.FileSystemObject" put (autoArgs, "Class", ScriptingObj) oleMethod(Scripting, "CreateObject", autoArgs)
clearautoArgs string DoorsFileName = "C:/Temp/TestDoors.txt" put (autoArgs, "FileName", DoorsFileName) oleMethod(Scripting, "CreateTextFile", autoArgs)
//But then I want to write something into that file but it's not working for now... what i've tried yet: clearautoArgs string textInhalt = "This is a Test" put (autoArgs, "Text", textInhalt) oleMethod(Scripting, "WriteLine", autoArgs)
// I also tried this without success:
clearautoArgs string test = "CreateObject(\"Scripting.FileSystemObject\").CreateTextFile(\"C:\\Temp\\TestDoors.txt\").WriteLine \"This is a Test\"" printtest oleMethod(Scripting, test) //in VBA this Code is working So if anyone has a solution for this problem, it would be very helpfull. Best Regards, Julian
meiju011 - Wed Dec 11 04:20:29 EST 2013 |
Re: Writing into a Textfile with oleMethod Hi, Why don't you use the native DXL functions? Alain |
Re: Writing into a Textfile with oleMethod adevicq - Wed Dec 11 04:40:32 EST 2013 Hi, Why don't you use the native DXL functions? Alain Hi, I just want to increase my skills with OleAutomation :) got it working now ... OleAutoObj Scripting = oleCreateAutoObject("Scripting.FileSystemObject"); OleAutoArgs autoArgs = create(); OleAutoObj objDocThis = null
void closeIfNonNull(OleAutoObjo) { if(!null o) { oleCloseAutoObject(o) o = null } /* the close perm will automatically set o to null for us */ }
string ScriptingObj = "Scripting.FileSystemObject" put (autoArgs, "Class", ScriptingObj) oleMethod(Scripting, "CreateObject", autoArgs)
clearautoArgs string DoorsFileName = "C:/Temp/TestDoors.txt" put (autoArgs, "FileName", DoorsFileName) oleMethod(Scripting, "CreateTextFile", autoArgs, objDocThis)
clearautoArgs string textInhalt = "Das ist ein Test ob der Zugriff funktioniert" put (autoArgs, "Text", textInhalt) oleMethod(objDocThis, "WriteLine", autoArgs)
closeIfNonNull Scripting closeIfNonNull objDocThis deleteautoArgs
|